class CategoriesController < ApplicationController

  before_filter :view_level_check, :only=>[:show_category_posts]

	layout "posts"

	def index
		@categories = Category.find(:all)
	end

	def show_category_posts
		@category = Category.find_by_id(params[:id])
    if @category.nil?
      render :file=>"public/404.html", :status => 404
    end
	end

  protected
  def view_level_check
    return true if User.get_user_level_id(session[:user_id]) <= Category.view_level_id(params[:id])
    session[:denied_path] = request.request_uri
    redirect_to denied_path
  end

end
